/*    */ package com.zimbra.cs.redolog.op;
/*    */ 
/*    */ import com.zimbra.common.mailbox.Color;
/*    */ import com.zimbra.cs.mailbox.MailItem.Type;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.cs.mailbox.MailboxOperation;
/*    */ import com.zimbra.cs.redolog.RedoLogInput;
/*    */ import com.zimbra.cs.redolog.RedoLogOutput;
/*    */ import com.zimbra.cs.redolog.Version;
/*    */ import java.io.IOException;
/*    */ import java.util.Arrays;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class ColorItem
/*    */   extends RedoableOp
/*    */ {
/*    */   private int[] mIds;
/*    */   private MailItem.Type type;
/*    */   private long mColor;
/*    */   
/*    */   public ColorItem()
/*    */   {
/* 40 */     super(MailboxOperation.ColorItem);
/*    */   }
/*    */   
/*    */   public ColorItem(int mailboxId, int[] ids, MailItem.Type type, Color color) {
/* 44 */     this();
/* 45 */     setMailboxId(mailboxId);
/* 46 */     this.mIds = ids;
/* 47 */     this.type = type;
/* 48 */     this.mColor = color.getValue();
/*    */   }
/*    */   
/*    */   protected String getPrintableData()
/*    */   {
/* 53 */     StringBuffer sb = new StringBuffer("id=");
/* 54 */     sb.append(Arrays.toString(this.mIds)).append(", color=").append(this.mColor);
/* 55 */     return sb.toString();
/*    */   }
/*    */   
/*    */   protected void serializeData(RedoLogOutput out) throws IOException
/*    */   {
/* 60 */     out.writeInt(-1);
/* 61 */     out.writeByte(this.type.toByte());
/*    */     
/* 63 */     out.writeLong(this.mColor);
/* 64 */     out.writeInt(this.mIds == null ? 0 : this.mIds.length);
/* 65 */     if (this.mIds != null) {
/* 66 */       for (int i = 0; i < this.mIds.length; i++) {
/* 67 */         out.writeInt(this.mIds[i]);
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   protected void deserializeData(RedoLogInput in) throws IOException {
/* 73 */     int id = in.readInt();
/* 74 */     if (id > 0)
/* 75 */       this.mIds = new int[] { id };
/* 76 */     this.type = MailItem.Type.of(in.readByte());
/* 77 */     if (getVersion().atLeast(1, 27)) {
/* 78 */       this.mColor = in.readLong();
/*    */     } else
/* 80 */       this.mColor = in.readByte();
/* 81 */     if (id <= 0) {
/* 82 */       this.mIds = new int[in.readInt()];
/* 83 */       for (int i = 0; i < this.mIds.length; i++) {
/* 84 */         this.mIds[i] = in.readInt();
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   public void redo() throws Exception {
/* 90 */     int mboxId = getMailboxId();
/* 91 */     Mailbox mailbox = MailboxManager.getInstance().getMailboxById(mboxId);
/* 92 */     mailbox.setColor(getOperationContext(), this.mIds, this.type, Color.fromMetadata(this.mColor));
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/ColorItem.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */